package br.com.dubs.core.ejb;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import br.com.dubs.core.interfaces.MsgHandlerInterface;
import br.com.dubs.persistence.dao.ClientDAO;
import br.com.dubs.persistence.entities.ClientEntity;
import br.com.dubs.persistence.entities.MsgEntity;
import br.com.dubs.persistence.exceptions.GenericDAOException;

@Stateless
public class MsgHandler implements MsgHandlerInterface {
	@EJB
	private ClientDAO clientDAO;

	public Boolean sendMSG(MsgEntity msg) {
		ClientEntity client = msg.getReceiver();
		client = msg.getReceiver();
		client.getReceivedMsg().add(msg);
		try {
			clientDAO.update(client);
		} catch (GenericDAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return true;
	}
}
